package com.xiaolun.controller;

import com.xiaolun.mapper.OrderMapper;
import com.xiaolun.pojo.Order;
import com.xiaolun.util.LayuiResponse;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.ResponseBody;

import java.util.List;


@Controller
public class OrderSearch {

    @Autowired
    private OrderMapper orderMapper;

    @RequestMapping(value = "/search",method = RequestMethod.POST)
    @ResponseBody
    public Object login(@RequestBody Order order){
        if (order.getOrderNo().equals("")){
            order.setOrderNo(null);
        }
        if (order.getOrdername().equals("")){
            order.setOrdername(null);
        }
        if (order.getOrdertype().equals("")){
            order.setOrdertype(null);
        }
        if (order.getOrderstatus().equals("")){
            order.setOrderstatus(null);
        }

        List<Order> userList = this.orderMapper.SearchOrder(order); //查询到的数据列表
        //将查询到的数据返回回去，列表形式
        return new LayuiResponse(0, "请求成功", userList, userList.size()); //将数据带回去
    }
}
